package LanQiao;

import java.util.Scanner;
import java.util.Stack;

public class Demo1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n = scan.nextInt();//测试的案例组数
        while (n > 0) {
            n--;
            long num = scan.nextLong();
            int k = scan.nextInt();
            int x = scan.nextInt();
            while (k != 0) {
                k--;
                Stack<Long> stack = new Stack<>();
                long num1 = num;
                while (num1 != 0) {//将num1每一位放入栈中
                    stack.push(num1 % 10);
                    num1 /= 10;
                }
                while (!stack.isEmpty()) {
                    long key = stack.pop();
                    if (key + x < 10) {
                        num1 = num1 * 10 + (key + x);
                    } else {
                        num1 = num1 * 100 + (key + x);
                    }
                }
                num = num1;
            }
            System.out.println(num % 1000000007);
        }
        scan.close();
    }
}
